package pers.litao.bit.commons.utils;

import java.io.Serializable;
import java.util.HashMap;

/**
 * 统一返回数据类型
 *
 * @author 李涛
 * @date 2020-11-15 13:41
 */
public class R extends HashMap<String,Object> implements Serializable {
    private static final long serialVersionUID = 1L;

    public R(){
        put("code", 0);
        put("message", "成功");
        put("data", null);
    }
    private R(Object data){
        put("code", 0);
        put("message", "成功");
        put("data", data);
    }
    private R(Integer code ,String message,Object data){
        put("code", code);
        put("message", message);
        put("data", data);
    }
    public static R ok(){
        return new R();
    }
    public static R ok(Object data){
        return new R(data);
    }
    public static R error(Integer code,String message,Object data){
        return new R(code,message,data);
    }

}
